<template>
<view class="user-promote-order" v-if="level!=0">
	<view class="user-assets-content flex  flex-wrap">
		<view class="user-item flex-col col-center">
			<tool-tip v-if="false" class="m-t-20" id="today-profit" content="今日预估收益金额"
				style="position: absolute;right: -66rpx;"></tool-tip>
			<view class="nr user-assets-name flex" style="color: #333333">
				支付订单数
				<!-- <u-icon class="ml10" name="question-circle" size="30rpx" color="#D88D5A" /> -->
			</view>
			<view class="assets m-l-20">
				<text class="xxl primary bold">{{totalNum.total_order_num}}</text>
			</view>
		</view>
		<view class="user-item flex-col col-center">
			<view class="nr user-assets-name flex" style="color: #333333">
				支付金额
				<!-- <u-icon class="ml10" name="question-circle" size="30rpx" color="#D88D5A" /> -->
			</view>
			<view class="assets m-l-20">
				<price-format weight="bold" :first-size="36" :subscript-size="26" :second-size="36"
					:price="totalNum.total_price" :color="colorConfig.primary" />
			</view>
		</view>
		<view class="user-item flex-col col-center">
			<view class="nr user-assets-name flex" style="color: #333333">
				预估收益
				<!-- <u-icon class="ml10" name="question-circle" size="30rpx" color="#D88D5A" /> -->
			</view>
			<view class="assets">
				<price-format weight="bold" :first-size="36" :subscript-size="26" :second-size="36"
					:price="totalNum.total_earnings" :color="colorConfig.primary" />
			</view>
		</view>
	</view>
   <tabs :current="active" @change="onChange" bar-width="60" :is-scroll="false">
       <tab v-for="(item, index) in orderDate" :key="index" :name="item.name">
           <spread-order ref="spreadOrder" :i="index" :index="active" :level="level" :date="item.type" @totalData="total"></spread-order>
       </tab>
   </tabs>
</view>
<view class="user-promote-order" v-else>
   <tabs :current="active" @change="onChange" bar-width="60" :is-scroll="false">
       <tab v-for="(item, index) in order" :key="index" :name="item.name">
           <spread-order :type="item.type" :i="index" :index="active"></spread-order>
       </tab>
   </tabs>
</view>
</template>

<script>

import { distributionOrder } from "@/utils/type";

export default {
  data() {
    return {
      order: [{
        name: "全部",
        type: distributionOrder.ALL,
      }, {
        name: "待返佣",
        type: distributionOrder.WAIT_RETURN,
      }, {
        name: "已结算",
        type: distributionOrder.HANDLED,
      }, {
        name: "已失效",
        type: distributionOrder.INVALED,
      }, {
        name: "提现中",
        type: distributionOrder.WITHDRAWALING,
      }, {
        name: "已提现",
        type: distributionOrder.WITHDRAWALED,
      }],
	  orderDate: [{
	    name: "今日数据",
	    type: "today",
	  }, {
	    name: "昨日数据",
	    type: "yesterday",
	  }, {
	    name: "本月数据",
	    type: "this_month",
	  }, {
	    name: "上月数据",
	    type: "last_month",
	  }, {
	    name: "全部",
	    type: "all",
	  }],
      active: distributionOrder.ALL,
	  date:'',
	  level:0,
	  totalNum: {total_earnings: 0, total_price: 0, total_order_num: 0, total_count: 0}
    };
  },


  onLoad: function (options) {
  	this.level=this.$Route.query.level
  	this.date=this.$Route.query.date
	if (this.level==1) {
		uni.setNavigationBarTitle({
			title:"我的店铺数据"
		})
	} else if(this.level==2 ) {
		uni.setNavigationBarTitle({
			title:"我的团队数据"
		})
	}
  },
  onShow() {
  },
  methods: {
    onChange(index) {
      this.active = index
	  console.log("this.$refs.spreadOrder",this.$refs.spreadOrder)
	  this.$refs.spreadOrder[index].showUserSpreadOrder()
	  this.total()
    },
	total(data){
		this.totalNum=data
		console.log('this.total',data)
	}
  }
};
</script>
<style lang="scss" scoped>
	.user-assets-content {
		padding-top: 30rpx;
		background-color: $-color-white;	
		.user-item {
			flex: 1;
			position: relative;
			
			.user-assets-name {
				text-align: center;
				
			}
			
			.assets {
				margin-top: 14rpx;
				text-align: center;
				
			}
		}
	}
</style>